﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Practices.Prism.ViewModel;
using Microsoft.Practices.Prism.Commands;
using RecorderSound.Model;
using System.Collections.ObjectModel;
using System.Collections.Generic;


namespace RecorderSound.ViewModel
{
    public class ViewModelBase : NotificationObject
    {
        #region members
        public readonly IRecorder _record;
        public Record rec;
        public ObservableCollection<List> listDataSource = new ObservableCollection<List>();
        public Storage s;
        List list;
        public string _Name{get; set;}
        public string _Count { get; set; }
        public int liczba {get; set;}
       
        #endregion

        public ViewModelBase()
        {
            this.s = new Storage();
            this.rec = new Record();
            StartRecorder = new DelegateCommand(()=>start());
            StopRecorder = new DelegateCommand(()=>stop());
            PlayRecorder = new DelegateCommand(()=>play());
            
            add = new DelegateCommand(() => save());
        }

   
        #region Delegate Commands

        public DelegateCommand StartRecorder { get; set; }
        public DelegateCommand StopRecorder { get; set; }
        public DelegateCommand PlayRecorder { get; set; }
        public DelegateCommand add { get; set; }
       
        #endregion 

        #region manipulation microphone
        //method that manipulate microphone 
        public void start()
        {
            this.rec.StartRecord();
        }
        public void stop()
        {
            this.rec.StopRecord();
        }
        public void play()
        {
            this.rec.PlayRecord();
        }
        #endregion


        public void save()
        {
           // this.s.SaveFile();
         
            list = new List(Name);
            listDataSource.Insert(0,list);
        }
        
        public string Name
        {
            get
            {
                return _Name;
            }
            set
            {
                
                
                    _Name = value;
                    RaisePropertyChanged(() => Name);
                
            }
        }


     

        public ObservableCollection<List> DataSource
        {
            get
            {

                if (this.listDataSource == null)
                {
                    this.listDataSource = new ObservableCollection<List>();
                }
                return this.listDataSource;
            }
            set
            {
                if (this.listDataSource != value)
                {
                    this.listDataSource = value;
                    this.RaisePropertyChanged(() => DataSource);
                }
            }
        }
         
    }
}
